package org.example.springbootdeptemp.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.springbootdeptemp.dto.PageBean;
import org.example.springbootdeptemp.pojo.Emp;

import java.util.List;

@Mapper
public interface EmpMapper {

    int update(Emp emp);

    int delete(Integer[] ids);

    List<Emp> selectPageEmps(PageBean<Emp> emp);

    int count(PageBean<Emp> emp);

    @Select("select * from emp where id=#{id}")
    Emp selectEmpById(Integer id);

    @Insert("insert into emp (username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "VALUES (#{username},#{password},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},now(),now()) ")
    int insertEmp(Emp emp);

    @Select("select * from emp where dept_id=#{deptId}")
    List<Emp> selectByDeptId(Integer deptId);

    List<Emp> getEmpByPage(PageBean<Emp> emp);
}
